<template>
  <div>
    <img alt="Vue logo" src="./assets/logo.png">
    <div class="input-output-container">
      <!-- 实时输入：v-model 双向绑定输入内容 -->
      <input 
        type="text" 
        v-model="inputText" 
        placeholder="请输入内容"
      >
      <!-- 子组件：传递输入内容和清空事件 -->
      <HelloWorld 
        :msg="inputText" 
        @clear="handleClear"
      />
    </div>
  </div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue';

export default {
  name: 'App',
  components: {
    HelloWorld
  },
  data() {
    return {
      inputText: '' // 初始化输入内容
    };
  },
  methods: {
    handleClear() {
      this.inputText = ''; // 清空输入内容
    }
  }
};
</script>

<style>
#app {
  /* 原有样式保持不变 */
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.input-output-container {
  margin-top: 20px; /* 调整输入框和子组件与图标的间距 */
}
</style>